package com.film.service.impl.movie;

import com.alibaba.fastjson.JSONObject;
import com.film.service.movie.MovieCommentService;
import com.film.utils.MySqlConnection;
import org.springframework.stereotype.Service;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

@Service
public class MovieCommentServiceImpl implements MovieCommentService {
    @Override
    public JSONObject comment(Integer movieId, String comment, Integer commentatorId) throws SQLException {
        JSONObject resp = new JSONObject();
        //插入评论
        String sql = "insert into Movie_Comments(movie_id, comment, commentator_id) value(" +  movieId + "," + " '" + comment + "'," + commentatorId + ")";
        System.out.println(sql);
        Statement stmt = MySqlConnection.connect.createStatement();
        stmt.execute(sql);
        resp.put("error_message", "插入成功");


        return resp;

    }
}
